﻿using Whoever.Patterns.Business;

using EditorialProyectos.Business.Entities;
using EditorialProyectos.DataAccess.Repositories;
using System.Collections.Generic;
using System.Linq;

namespace EditorialProyectos.Business
{
    public class CommentManager : Manager<Comment>
    {
        public CommentManager()
            : base(RepositoryFactory.CommentRepository)
        {

        }

        public IEnumerable<Comment> GetByProjectId(int projectId)
        {
            var comments = ManagerRepository.CommentRepository.QueryFactory.GetAll();

            var result = comments.Where(u => u.ProjectId == projectId).ToList();

            foreach(var item in result)
            {
                item.Project = null; // TODO: MATIAS VER
            }

            return result;
        }
    }
}
